<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script>
			var name = "窗前明月光，疑是地上霜";
			document.write("长度:" + name.length+"<br />");
			document.write("光的位置：" + name.indexOf("光")+"<br />");
//			字符串明月的位置
			var weiZhi=name.indexOf("明月");
			var jiequ=name.substring(weiZhi,weiZhi+2);
			document.write("截取明月:"+jiequ);
		</script>
	</body>

</html>